/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbeans.livechat;


import java.io.Serializable;
import java.util.Date;

/**
 *
 * @author Dezmond
 */
public class LiveMessage implements Serializable, Comparable<LiveMessage>{
    private String username;
    private Date datetime;
    private String messageBody;

    public LiveMessage(String username, Date datetime, String messageBody) {
        this.username = username;
        this.datetime = datetime;
        this.messageBody = messageBody;
    }

    public LiveMessage() {
       
    }
    

    public Date getDatetime() {
        return datetime;
    }

    public void setDatetime(Date datetime) {
        this.datetime = datetime;
    }

    public String getMessageBody() {
        return messageBody;
    }

    public void setMessageBody(String messageBody) {
        this.messageBody = messageBody;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public int compareTo(LiveMessage comparable) {
        if(this.getDatetime().before(comparable.getDatetime())){
            return 1;
        } else if(this.getDatetime().after(comparable.getDatetime())){
            return -1;
        } else {
            return 0;
        }
    }
    
    
}
